package com.whalehearing.tingyou.api.controller.hearing;

import com.whalehearing.tingyou.common.annotation.DataSource;
import com.whalehearing.tingyou.common.annotation.Log;
import com.whalehearing.tingyou.common.core.controller.BaseController;
import com.whalehearing.tingyou.common.core.domain.AjaxResult;
import com.whalehearing.tingyou.common.core.page.TableDataInfo;
import com.whalehearing.tingyou.common.enums.BusinessType;
import com.whalehearing.tingyou.common.enums.DataSourceType;
import com.whalehearing.tingyou.common.utils.poi.ExcelUtil;
import com.whalehearing.tingyou.domain.HearingDetailedQuestionnaire;
import com.whalehearing.tingyou.domain.HearingDetailedQuestionnaire;
import com.whalehearing.tingyou.service.IHearingDetailedQuestionnaireService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;

/**
 * 详细问卷Controller
 *
 * @author zengjun-qxm
 * @date 2024-09-20
 */
@Api(tags="api用户详细问卷管理")
@RestController
@RequestMapping("/api/hearing/questionnaire")
public class ApiHearingDetailedQuestionnaireController extends BaseController
{
    @Autowired
    private IHearingDetailedQuestionnaireService hearingDetailedQuestionnaireService;

    /**
     * 根据-userId-查询用户详细问卷详细信息
     */
    @ApiOperation("根据-userId-查询用户详细问卷详细信息")
    @GetMapping(value = "/getHearingDetailedQuestionnaireByUserId/{userId}")
    public AjaxResult getHearingDetailedQuestionnaireByUserId(@PathVariable Long userId) {
        List<HearingDetailedQuestionnaire> hearingDetailedQuestionnaireList = hearingDetailedQuestionnaireService.getHearingDetailedQuestionnaireByUserId(userId);
        return success(hearingDetailedQuestionnaireList);
    }

    /**
     * 新增用户详细问卷
     */
    @ApiOperation("新增用户详细问卷")
    @Log(title = "用户详细问卷", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HearingDetailedQuestionnaire hearingDetailedQuestionnaire) {
        return toAjax(hearingDetailedQuestionnaireService.save(hearingDetailedQuestionnaire));
    }

    /**
     * 根据-详细问卷id-删除用户详细问卷
     */
    @ApiOperation("根据-详细问卷id-删除用户详细问卷")
    @Log(title = "用户详细问卷", businessType = BusinessType.DELETE)
    @DeleteMapping("/{detailedQuestionnaireIds}")
    public AjaxResult remove(@PathVariable Long[] detailedQuestionnaireIds) {
        return toAjax(hearingDetailedQuestionnaireService.removeByIds(Arrays.asList(detailedQuestionnaireIds)));
    }
}
